﻿@model ADZ_GoodsCategory
@{
    Layout = "~/Views/Shared/_ContentLayout.cshtml";

    var viewModel = Model ?? new ADZ_GoodsCategory();
    ADZ_MasterEntities dbcontext = new ADZ_MasterEntities();
    Dictionary<string, string> dc = new Dictionary<string, string>();
}
<form id="S_Form" action="@Url.Action("add", "category")" me method="post" class="definewidth m20" enctype="multipart/form-data">
    <table class="table table-bordered table-hover definewidth m10">
        <tr>
            <td colspan="2" style="width:50%">
                <h5>@ViewBag.Title</h5>
                <input type="hidden" value="@viewModel.category_id" name="category_id" id="category_id" />
            </td>
        </tr>
        <tr>
            <td width="6%" class="tableleft">分类名称<em>*</em></td>
            <td>
                <input type="text" name="category_name" style="width:300px;" value="@Model.category_name" />
            </td>
        </tr>
        <tr>
            <td width="6%" class="tableleft">分类英文名称</td>
            <td>
                <input type="text" name="category_name_en" style="width:300px;" value="@Model.category_name_en" />
            </td>
        </tr>
        <tr>
            <td width="6%" class="tableleft">父商品分类<em>*</em></td>
            <td>
                <select id="parent_id" name="parent_id">
                    @{
                        dc = new Dictionary<string, string>();
                        dc.Add("0", "顶级分类");
                        ADZ_GoodsCategoryBiz.Instance.GetParentSunList().ForEach(t =>
                        {
                            dc.Add(t.category_id.ToString(), t.category_name);
                        });
                    }
                    @HtmlPagerHelper.ShowSelectOpton(dc, viewModel.parent_id.ToString())
                </select>&nbsp;
            </td>
        </tr>
        <tr>
            <td width="6%" class="tableleft">是否显示<em>*</em></td>
            <td>
                <select id="is_show" name="is_show">
                    @{
                        dc = new Dictionary<string, string>();
                        dc.Add("0", "不显示");
                        dc.Add("1", "显示");
                    }
                    @HtmlPagerHelper.ShowSelectOpton(dc, viewModel.is_show.ToString());
                </select>&nbsp;
            </td>
        </tr>
        <tr>
            <td class="tableleft"></td>
            <td colspan="3">
                <p><span id="spMsg"></span></p>
                <button type="submit" class="btn btn-primary">保存</button> &nbsp;&nbsp;
                @if (viewModel.category_id > 0)
                {
                    <button type="button" class="btn btn-success" name="backid" id="backid">返回</button>
                }
            </td>

        </tr>
    </table>
    <script>
        BUI.use('bui/overlay', function (overlay) {
            $(function () {
                var validator = $('form').validate({
                    errorLabelContainer: $("#errorContainer"),
                    errorElement: "span",
                    rules: {
                        category_name: { required: true }
                    },
                    messages: {
                        category_name: { required: "请输入分类名称" }
                    },
                    submitHandler: function (form) {
                        $(form).ajaxSubmit(function (result) {
                            ShowActionResult(result, function () { self.location = document.referrer; });
                        });
                    }
                });

            });
        });
    </script>
</form>

